﻿using System.Collections.Generic;

namespace Indt.Components
{
    public class Group<K, T> : List<T>
    {
        public K Key;

        public Group(K Key)
        {
            this.Key = Key;
        }
    }
    
    public class GroupList<K, T> : List<Group<K, T>>
    {
        public void addItem(K key, T item)
        {
            Group<K, T> g = this.Find((x) => x.Key.Equals(key));

            if (g != null)
            {
                g.Add(item);
            }
            else
            {
                Group<K, T> group = new Group<K, T>(key);
                group.Add(item);
                this.Add(group);
            }
        }
    }
}